package com.jack.payment.rabbitmq.entity;


import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(value=JsonInclude.Include.NON_NULL)
@Schema(name = "统一封装队列消息", description = "用于队列消费失败后的异常(错误等)日志记录, 方便排查")
public class QueueContentModel<T> implements Serializable {
    @Schema(description = "数据库名称")
    private String dbName;
    @Schema(description = "是否为手动触发")
    private Integer isManual;
    @Schema(description = "队列全系统唯一id")
    private String id;
    @Schema(description = "消息主题 [1: 请求日志 2: 支付消息 3: 退款 4: 登录]")
    private Integer subject;
    @Schema(description = "发送队列数据")
    private T data;
    @Schema(description = "是否为重复消息状态 [0 不是 1: 是  2 重发消息]")
    private Integer status;
    @Schema(description = "消费次数, 可自定义消费多少后, 手动确认消息, 并使用推送等方式及时提醒管理员")
    private Integer count;
    @Schema(description = "第一次发送时间")
    private Long sendDate;
    @Schema(description = "延迟时间")
    private Long delayTime;
    @Schema(description = "队列路由")
    private String exchange;
    @Schema(description = "队列名称")
    private String queueName;
    @Schema(description = "最后一次消费时间")
    private Long lastDate;
    @Schema(description = "成功消费时间")
    private Long successDate;
    @Schema(description = "详细异常错误信息")
    private String exceptionInfo;
    @Schema(description = "是否为延迟队列")
    private boolean isDelayQueue;
    @Schema(description = "需要转换的实体类")
    private String attachClass;


    public QueueContentModel(QueueContentModel queueContentModel) {
        this.isManual = 0;
        this.dbName = queueContentModel.getDbName();
        this.id = queueContentModel.getId();
        this.status = queueContentModel.getStatus();
        this.count = queueContentModel.getCount();
        this.sendDate = queueContentModel.getSendDate();
        this.subject = queueContentModel.getSubject();
    }
}
